from xgolib import XGO
import time
from ultralytics import YOLO
import cv2
import os
from detect import Detector
from DogControl import DogController
''' 
控制上下左右移动，行走的时间，步伐固定20
控制转身，控制转身时间
进行危险标志识别按钮
进行抓取按钮
进行识别圆柱台和长方条的颜色按钮
'''
dog_control = DogController()
det = Detector()
def Move():
    direct = input("请输入运动方向，后和右在后面输入:x(前),y(左),X(后),Y(右)")
    t = float(input("请输入运动时间:"))
    dog_control.move(direct,t)
def Turn():
    angle = int(input("请输入旋转角度:90(逆时针),-90(顺时针)"))
    t = float(input("请输入转身时间:"))
    dog_control.turn(angle,t)
def DangerDetect():
    result = det.detect_once_dange()
    print(result["speech_text"])
def ShapeDetect():
    result = det.detect_once_shape()
    print(result["speech_text"])    
def CathchOrPut():
    op = input("输入c表示抓取,p表示放置:")
    if op == 'c':
        Cathch()
    else:
        PutOn()
def Cathch():
    dog_control.catch_from_ground()
def PutOn():
    dog_control.put_on_cylinder()

def main():
    while True:
        op = int(input('''\n
        1. 进行移动(上下左右)\n
        2. 进行转身\n
        3. 进行危险标志识别\n
        4. 进行抓,放\n
        5. 识别形状          
        '''))
        if op == 1:
            Move() 
        elif op == 2:
            Turn() 
        elif op == 3:
            DangerDetect() 
        elif op == 4:
            CathchOrPut()
        elif op == 5:
            ShapeDetect()
        else:
            print("输出错误，范围1~5，请重新输入!!")
            continue 

# pos: "方向 时间"
array = {"pos1":["y 1.5","x 3.5"]}
if __name__ == "__main__":
    main()



             





